home *** CD-ROM | disk | FTP | other *** search
/ HamCall (April 1991) / HAMCALL CD-ROM (Buckmaster)(April 1991).BIN / prgming / ctutor / define.c < prev    next >
Text File  |  1990-10-14  |  780b  |  35 lines

  1.                                         /* Chapter 6 - Program 1 */
  2. #define START  0  /* Starting point of loop */
  3. #define ENDING 9  /* Ending point of loop */
  4. #define MAX(A,B)  ((A)>(B)?(A):(B))  /* Max macro definition */
  5. #define MIN(A,B)  ((A)>(B)?(B):(A))  /* Min macro definition */
  6.  
  7. main()
  8. {
  9. int index,mn,mx;
  10. int count = 5;
  11.  
  12.    for (index = START;index <= ENDING;index++) {
  13.       mx = MAX(index,count);
  14.       mn = MIN(index,count);
  15.       printf("Max is %d and min is %d\n",mx,mn);
  16.    }
  17. }
  18.  
  19.  
  20.  
  21. /* Result of execution
  22.  
  23. Max is 5 and min is 0
  24. Max is 5 and min is 1
  25. Max is 5 and min is 2
  26. Max is 5 and min is 3
  27. Max is 5 and min is 4
  28. Max is 5 and min is 5
  29. Max is 6 and min is 5
  30. Max is 7 and min is 5
  31. Max is 8 and min is 5
  32. Max is 9 and min is 5
  33.  
  34. */
  35.